/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

$(function () {
	//自定义错误提示信息
	var showmsg = function (msg) {
		$(".quickTishi").text(msg);
	};

	//快速注册预订
	var reg = $("#register").Validform({
		btnSubmit: "#quickRegst",
		tipSweep: true,
		showAllError: false,
		ajaxPost: true,
		tiptype: function (msg) {
			showmsg(msg);
		},
		beforeSubmit: function (curform) {
			loading("false");
		}
	});
	reg.addRule([
		{
			ele: "#mobile",
			ajaxurl: "/user/quickrealtion",
			datatype: "m",
			sucmsg: " ",
			errormsg: "请输入正确的手机号！",
			maxlength: "11"
		},
		{
			ele: "#email",
			ajaxurl: "/user/quickrealtion",
			datatype: "e",
			sucmsg: " ",
			errormsg: "请输入正确的邮箱号!"
		}
	]);
	reg.config({
		ajaxpost: {
			success: function (data) {
				if (data.code > 0) {
					loading("true");
					$("#quickBox").css("display", "none");
					$("#quickBox2").css("display", "block");
				}
			}
		}
	});

	//快速登录预定
	var log = $("#login").Validform({
		btnSubmit: "#quickLogin",
		tipSweep: true,
		showAllError: false,
		ajaxPost: false,
		tiptype: function (msg) {
			showmsg(msg);
		},
		beforeSubmit: function (curform) {
			loading("false");
		}

	});
	log.addRule([
		{
			ele: "#username",
			datatype: "m|e",
			sucmsg: " ",
			errormsg: "请输入正确的手机或邮箱",
			tip: "邮箱/手机号",
			altercss: "gray",
			value: "邮箱/手机号"
		},
		{
			ele: "#password",
			datatype: "*6-20",
			sucmsg: " "
		}
	]);
});

//设置loading
function loading(flag) {
	if (flag == "true") {
		$("#loading").css("display", "none");
	} else {
		$("#loading").css("display", "block");
	}
}

